﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace _18.Exercise
{
    class Program
    {
        static void Main(string[] args)
        {
            string text = "Write bal@email.com a program gone@abv.bg for extracting all email addresses ";
            MatchCollection emails = Regex.Matches(text, @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?");
            foreach (Match item in emails)
            {
                Console.WriteLine(item);
            }
        }
    }
}
